package com.gcstorage.tvdev.bean;

import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;

import com.gcstorage.tvdev.constants.AppConstant;
import com.gcstorage.tvdev.constants.GlobalConstants;
import com.gcstorage.tvdev.util.SpUtils;

/**
 * 小程序对象
 * created by Sanpark on 2020-10-27 19:38
 */
public class H5AppInfo implements Parcelable {

    /**
     * id : 4ddd9019419647fdb24a16d5bf130477
     * packageName : cpfk
     * hostUrl :
     * appName : 产品反馈
     * appIcon : http://113.57.92.149:8768/group1/default/20200923/14/43/8/1600843439639.png
     * appDescrible : 产品反馈
     * appType : 20
     * createTime : 2020-09-21 10:57:08
     * appStatus : 1
     * packageUrl : http://113.57.92.149:13201/xxfk/#/index
     * versionNum : 1.0
     * versionDescrible :
     * kind : 1
     * kindName : 指挥调度
     * developers :
     * appSize :
     * updateTime :
     * appTitle :
     * downloadCount : null
     * tenantId : 000000
     * type : false
     * flag : false
     * uuid : null
     * doloadCount : null
     */
    private String appId;
    private String id;
    private String packageName;
    private String hostUrl;
    private String appName;
    private String appIcon;
    private String appDescrible;
    private String appType;
    private String createTime;
    private String appStatus;
    private String packageUrl;
    private String versionNum;
    private String versionDescrible;
    private String kind;
    private String kindName;
    private String developers;
    private String appSize;
    private String updateTime;
    private String appTitle;
    private String downloadCount;
    private String tenantId;
    private boolean type;
    private boolean flag;
    private String uuid;
    private String doloadCount;
    private String downloadUrl;
    private String md5;
    private String params;

    public String getWebUrl() {
        return "file:///mnt/sdcard/gcstorage/app/" + SpUtils.getString(AppConstant.tenantId) + "/" + getAppId() + "/index.html" + getParams();
    }

    public String getProPath() {
        return GlobalConstants.H5_APP_DOWNLOAD_DIR + "/" + getAppId();
    }

    public String getProFile() {
        return getProPath() + "/index.html";
    }

    public String getZipPath() {
        return getProPath() + "/" + versionNum;
    }

    public String getZipFile() {
        return getZipPath() + "/vue.zip";
    }

    public String getParams() {
        return params == null ? "" : params;
    }

    public void setParams(String params) {
        this.params = params;
    }

    public String getAppId() {
        return TextUtils.isEmpty(appId) ? id : appId;
    }

    public void setAppId(String appId) {
        this.appId = appId;
    }

    public String getMd5() {
        return md5;
    }

    public void setMd5(String md5) {
        this.md5 = md5;
    }

    public String getDownloadUrl() {
        return downloadUrl;
    }

    public void setDownloadUrl(String downloadUrl) {
        this.downloadUrl = downloadUrl;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getPackageName() {
        return packageName;
    }

    public void setPackageName(String packageName) {
        this.packageName = packageName;
    }

    public String getHostUrl() {
        return hostUrl;
    }

    public void setHostUrl(String hostUrl) {
        this.hostUrl = hostUrl;
    }

    public String getAppName() {
        return appName;
    }

    public void setAppName(String appName) {
        this.appName = appName;
    }

    public String getAppIcon() {
        return appIcon;
    }

    public void setAppIcon(String appIcon) {
        this.appIcon = appIcon;
    }

    public String getAppDescrible() {
        return appDescrible;
    }

    public void setAppDescrible(String appDescrible) {
        this.appDescrible = appDescrible;
    }

    public String getAppType() {
        return appType;
    }

    public void setAppType(String appType) {
        this.appType = appType;
    }

    public String getCreateTime() {
        return createTime;
    }

    public void setCreateTime(String createTime) {
        this.createTime = createTime;
    }

    public String getAppStatus() {
        return appStatus;
    }

    public void setAppStatus(String appStatus) {
        this.appStatus = appStatus;
    }

    public String getPackageUrl() {
        return packageUrl;
    }

    public void setPackageUrl(String packageUrl) {
        this.packageUrl = packageUrl;
    }

    public String getVersionNum() {
        return versionNum;
    }

    public void setVersionNum(String versionNum) {
        this.versionNum = versionNum;
    }

    public String getVersionDescrible() {
        return versionDescrible;
    }

    public void setVersionDescrible(String versionDescrible) {
        this.versionDescrible = versionDescrible;
    }

    public String getKind() {
        return kind;
    }

    public void setKind(String kind) {
        this.kind = kind;
    }

    public String getKindName() {
        return kindName;
    }

    public void setKindName(String kindName) {
        this.kindName = kindName;
    }

    public String getDevelopers() {
        return developers;
    }

    public void setDevelopers(String developers) {
        this.developers = developers;
    }

    public String getAppSize() {
        return appSize;
    }

    public void setAppSize(String appSize) {
        this.appSize = appSize;
    }

    public String getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(String updateTime) {
        this.updateTime = updateTime;
    }

    public String getAppTitle() {
        return appTitle;
    }

    public void setAppTitle(String appTitle) {
        this.appTitle = appTitle;
    }

    public String getDownloadCount() {
        return downloadCount;
    }

    public void setDownloadCount(String downloadCount) {
        this.downloadCount = downloadCount;
    }

    public String getTenantId() {
        return tenantId;
    }

    public void setTenantId(String tenantId) {
        this.tenantId = tenantId;
    }

    public boolean isType() {
        return type;
    }

    public void setType(boolean type) {
        this.type = type;
    }

    public boolean isFlag() {
        return flag;
    }

    public void setFlag(boolean flag) {
        this.flag = flag;
    }

    public String getUuid() {
        return uuid;
    }

    public void setUuid(String uuid) {
        this.uuid = uuid;
    }

    public String getDoloadCount() {
        return doloadCount;
    }

    public void setDoloadCount(String doloadCount) {
        this.doloadCount = doloadCount;
    }


    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.appId);
        dest.writeString(this.id);
        dest.writeString(this.packageName);
        dest.writeString(this.hostUrl);
        dest.writeString(this.appName);
        dest.writeString(this.appIcon);
        dest.writeString(this.appDescrible);
        dest.writeString(this.appType);
        dest.writeString(this.createTime);
        dest.writeString(this.appStatus);
        dest.writeString(this.packageUrl);
        dest.writeString(this.versionNum);
        dest.writeString(this.versionDescrible);
        dest.writeString(this.kind);
        dest.writeString(this.kindName);
        dest.writeString(this.developers);
        dest.writeString(this.appSize);
        dest.writeString(this.updateTime);
        dest.writeString(this.appTitle);
        dest.writeString(this.downloadCount);
        dest.writeString(this.tenantId);
        dest.writeByte(this.type ? (byte) 1 : (byte) 0);
        dest.writeByte(this.flag ? (byte) 1 : (byte) 0);
        dest.writeString(this.uuid);
        dest.writeString(this.doloadCount);
        dest.writeString(this.downloadUrl);
        dest.writeString(this.md5);
        dest.writeString(this.params);
    }

    public void readFromParcel(Parcel source) {
        this.appId = source.readString();
        this.id = source.readString();
        this.packageName = source.readString();
        this.hostUrl = source.readString();
        this.appName = source.readString();
        this.appIcon = source.readString();
        this.appDescrible = source.readString();
        this.appType = source.readString();
        this.createTime = source.readString();
        this.appStatus = source.readString();
        this.packageUrl = source.readString();
        this.versionNum = source.readString();
        this.versionDescrible = source.readString();
        this.kind = source.readString();
        this.kindName = source.readString();
        this.developers = source.readString();
        this.appSize = source.readString();
        this.updateTime = source.readString();
        this.appTitle = source.readString();
        this.downloadCount = source.readString();
        this.tenantId = source.readString();
        this.type = source.readByte() != 0;
        this.flag = source.readByte() != 0;
        this.uuid = source.readString();
        this.doloadCount = source.readString();
        this.downloadUrl = source.readString();
        this.md5 = source.readString();
        this.params = source.readString();
    }

    public H5AppInfo() {
    }

    protected H5AppInfo(Parcel in) {
        this.appId = in.readString();
        this.id = in.readString();
        this.packageName = in.readString();
        this.hostUrl = in.readString();
        this.appName = in.readString();
        this.appIcon = in.readString();
        this.appDescrible = in.readString();
        this.appType = in.readString();
        this.createTime = in.readString();
        this.appStatus = in.readString();
        this.packageUrl = in.readString();
        this.versionNum = in.readString();
        this.versionDescrible = in.readString();
        this.kind = in.readString();
        this.kindName = in.readString();
        this.developers = in.readString();
        this.appSize = in.readString();
        this.updateTime = in.readString();
        this.appTitle = in.readString();
        this.downloadCount = in.readString();
        this.tenantId = in.readString();
        this.type = in.readByte() != 0;
        this.flag = in.readByte() != 0;
        this.uuid = in.readString();
        this.doloadCount = in.readString();
        this.downloadUrl = in.readString();
        this.md5 = in.readString();
        this.params = in.readString();
    }

    public static final Creator<H5AppInfo> CREATOR = new Creator<H5AppInfo>() {
        @Override
        public H5AppInfo createFromParcel(Parcel source) {
            return new H5AppInfo(source);
        }

        @Override
        public H5AppInfo[] newArray(int size) {
            return new H5AppInfo[size];
        }
    };
}
